home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
faq-s.zip
/
TIMEBANK.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-08-29
|
5KB
|
207 lines
program skeleton;
{
FAQ Door Skeleton
}
uses
Gentypes, { All type and constant declarations }
Configrt, { Configuration declarations / procedures }
Modem, { Modem support }
Statret, { System status declarations / procedures }
Gensubs, { General subroutines: lowest level }
Subs1, { First subroutine library }
Windows, { Routines to manage the split screen }
Subs2, { Second subroutine library: higher level I/O }
UserRet, { Does User Work for us }
init;
type bankrec = record
balance:integer;
lastt:char;
lasta:integer;
lastw:longint;
end;
var bnkfile:file of bankrec; acct:bankrec;
procedure returnfromdoor;
var t:sstr;
begin
readdataarea;
baudrate:=valu(paramstr(2));
online:=baudrate<>0;
local:=not online;
if baudrate=0 then baudrate:=defbaudrate;
setparam (usecom,baudrate,parity);
if unum=valu(paramstr(1)) then readurec else begin
unum:=valu(paramstr(1));
readurec;
if (unum<1) or (unum>numusers) then begin
unum:=-1;
exit
end;
logontime:=timer;
logofftime:=timer+urec.timetoday
end;
if hungupon then begin
unum:=-1;
exit
end;
fromdoor:=true;
settimeleft (urec.timetoday);
t:=paramstr(4);
if t=''
then returnto:='D'
else returnto:=upcase(t[1])
end;
procedure setuplocal;
var i:integer;
begin
assign(bnkfile,'TIMEBANK.ACC');
if not exist('timebank.acc') then begin
rewrite(bnkfile);
acct.balance:=0;
acct.lastw:=0;
acct.lastt:=' ';
acct.lasta:=0;
for i:=1 to 1200 do write(bnkfile,acct);
end;
reset(bnkfile); seek(bnkfile,unum-1);
read(bnkfile,acct);
end;
procedure quickrag;
begin
writeln; writeln('Don''t be a fool, ',unam);
end;
procedure writebank;
begin
seek(bnkfile,unum-1); write(bnkfile,acct);
end;
procedure showbalance;
begin
writehdr('Account #'+strr(unum)+' - '+unam); writeln;
writeln('Current balance : '^S,acct.balance,^R' minutes.');
write('Last Transaction: '^S);
case acct.lastt of
'W' : write('Withdrawal');
'D' : write('Deposit');
else begin
writeln('None');
writeln;
exit;
end;
end;
writeln(^R' of '^P,acct.lasta,^R' minutes on '^P,datestr(acct.lastw),^R);
writeln;
end;
procedure deposit;
var amt:integer;
begin
writeln;
if urec.timetoday <= 5 then begin
writeln('You have only ',urec.timetoday,' now!');
exit;
end;
if acct.balance = 60 then begin
writeln('The FTDC only insures you up to 60 minutes!');
exit;
end;
showbalance;
writestr('Deposit how many minutes? &');
amt:=valu(input); writeln;
if amt <= 0 then exit;
if amt > urec.timetoday then begin
quickrag;
writeln('You haven''t got that much left!');
exit;
end;
if amt+acct.balance > 60 then begin
writeln('The FTDC will only insure up to 60 minutes, would you settle for');
write ('depositing only '+strr(60-acct.balance)+' minutes instead? ');
writestr('&');
if upcase(input[1])<>'Y' then exit;
amt:=60-acct.balance;
end;
acct.lasta:=amt;
acct.lastw:=now;
acct.lastt:='D';
acct.balance:=acct.balance+amt;
urec.timetoday:=urec.timetoday-amt;
writebank;
writeln(^S,amt,^R' minutes added to your account.');
end;
procedure withdraw;
var amt:integer;
begin
writeln;
if acct.balance <= 0 then acct.balance:=0;
if acct.balance = 0 then begin
quickrag;
writeln('You have nothing to withdraw!');
exit;
end;
showbalance;
writestr('Withdraw how many minutes? &');
amt:=valu(input); writeln;
if amt <= 0 then exit;
if amt > acct.balance then begin
writeln('You haven''t got that much in your account.');
exit;
end;
acct.lasta:=amt;
acct.lastw:=now;
acct.lastt:='W';
acct.balance:=acct.balance-amt;
urec.timetoday:=urec.timetoday+amt;
writebank;
writeln(^S,amt,^R' minutes added to today''s time.');
end;
var q:char;
begin
readconfig;
validconfiguration;
initboard(true);
returnfromdoor;
setuplocal;
repeat
writeln (^P'['^S'Q'^P'] '^R'Quit');
writeln (^P'['^S'W'^P'] '^R'Withdraw Time');
writeln (^P'['^S'D'^P'] '^R'Deposit Time');
writeln (^P'['^S'B'^P'] '^R'Show Balance'^M);
writestr('[Time Bank Menu]: ');
q:=upcase(input[1]);
case q of
'Q': begin
writeln;
writeln('One moment, '^P+unam+^R', returning to FAQ.');
writeln; ensureclosed;
halt(0);
end;
'W': withdraw;
'D': deposit;
'B': showbalance;
end
until hungupon
end.